class Solution {
public:
    int count;
    vector<vector<int>> ret;
    vector<int> path;
    bool check[7] = {false};//标记这个数字是否被使用
    void dfs(vector<int>& nums)
    {
        if(path.size() == nums.size())
        {
            ret.push_back(path);
            return;
        }
        for(int i = 0;i<nums.size();i++)
        {
            if(!check[i])
            {
                path.push_back(nums[i]);
                check[i] = true;
                dfs(nums);
                //恢复现场
                path.pop_back();
                check[i] = false;
            }
        }
    }
    vector<vector<int>> permute(vector<int>& nums) {
        //解决方法为dfs
        count = nums.size();
        dfs(nums);//dfs寻找可能的答案
        return ret;
    }
};